//
//  HEIMGroupMemberItem.m
//  HealthElderly
//
//  Created by 吴欧 on 2021/11/22.
//  Copyright © 2021 honglutec. All rights reserved.
//

#import "HEIMGroupMemberItem.h"

@interface HEIMGroupMemberItem ()

@property (nonatomic, strong) UILabel *titleLb;

@property (nonatomic, strong) UIImageView *iconView;

@end

@implementation HEIMGroupMemberItem


- (instancetype)initWithFrame:(CGRect)frame {
    if (self=[super initWithFrame:frame]) {
        [self initUI];
    }
    return self;
}

- (void)initUI {
    _titleLb = [UILabel new];
    _titleLb.text = @"-";
    _titleLb.font = DYFont(16);
    _titleLb.numberOfLines = 1;
    _titleLb.textAlignment = NSTextAlignmentCenter;
    _titleLb.textColor = KHexColor(@"#5e5e5e");
    [self.contentView addSubview:_titleLb];
    
    _iconView = [UIImageView new];
    _iconView.contentMode = UIViewContentModeScaleAspectFill;
    _iconView.layer.masksToBounds = YES;
    _iconView.layer.cornerRadius = 5;
    [self.contentView addSubview:_iconView];
    
    CGFloat iw = (KScreenWidth - 6 * 20) / 5.0;
    
    [_iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).mas_offset(0);
        make.left.equalTo(self.contentView).mas_offset(-0);
        make.width.mas_offset(iw);
        make.height.mas_offset(iw);
    }];

    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_iconView.mas_bottom).mas_offset(5);
        make.left.equalTo(_iconView.mas_left).mas_offset(-0);
        make.right.equalTo(_iconView.mas_right).mas_offset(-0);
        make.bottom.equalTo(self.contentView).mas_offset(-10);
    }];
}

- (void)configCellWithModel:(HEIMKitInfo *)model indexPath:( NSIndexPath *) indexPath {
    _titleLb.text = model.showName;
    [_iconView sd_setImageWithURL:[NSURL URLWithString:model.avatarUrlString] placeholderImage: model.avatarImage];
}

@end
